/*
 * Copyright (C) 2010 M. Hautle.
 * 
 * This file is part of SimpleEL.
 * 
 * SimpleEL is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) any later version.
 * 
 * SimpleEL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License along with SimpleEL. If not, see <http://www.gnu.org/licenses/>.
 */
package ch.msoftch.internal;

/**
 * Interface for a cache.<br>
 * The implementation must be thread safe!<br>
 * However no guarantee is made about how fast a {@link #put(Object, Object)} value will be seen by a {@link #get(Object)} call!
 * 
 * @param <K> The key type
 * @param <V> The value type
 * @author M. Hautle
 */
public interface ICache<K, V> {

    /**
     * Returns the cached value for the given key.
     * 
     * @param key The key value
     * @return The cached value or null
     */
    V get(K key);

    /**
     * Puts the given value for the specified key.
     * 
     * @param key The key
     * @param value The value
     * @return The previous value or null
     */
    V put(K key, V value);

    /**
     * Clears the cache.
     */
    void clear();
}
